#include "SDL.h"
#include "SDL_image.h"
#include "engine.h"
#include "world.h"
#include "label.h"
#include <list>

#ifndef __menu_h__
#define __menu_h__

using namespace std;
using namespace labels;

namespace menu{
	
	//menu item
	class menu_item{
		protected:
			short x,y; //coodrinates
			label *active_l, *nactive_l, *current_l; //labels
			short id; //item number
			bool active;
			void (*action)(short);
		public:
			//constructor (active,not active, number,action)
			menu_item(label*, label*, short, void (*)(short));
			//function setting all necessary fields
			void set(label*, label*, short, void (*)(short));
			//tell menuitem to be active or not
			void set_activity(bool);
			//call action handler
			void do_action();
			//set item coordinates
			void set_xy(short nx, short ny);
			//draw item onscreen
			void draw(SDL_Surface*);
			//get item h and w
			short get_height();
			short get_width();
	};

	//menu itself
	class menu_world : public world{
		protected:
			list<menu_item> items;
			list<menu_item>::iterator current; //currently selected option
			SDL_Surface *background;
		public:
			//draw menu in center of the screen
			void draw(SDL_Surface*, SDL_Rect*);
			//do animation etc.
			void refresh(int);
			//react on incoming event
			void react(SDL_Event&);
			//add item on the end of the list
			void add_item(menu_item&);
			//select first item
			void select_first();
			//set background image
			void set_background(SDL_Surface*);
	};

	
	menu_world* make_menu();
	void quit();
}

#endif
